home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / totdoc.zip / CHAPT4.TXT < prev    next >
Text File  |  1991-02-11  |  19KB  |  475 lines

  1.                                                                      Determining
  2.                                                                                &
  3.                                                                      Controlling
  4.                                                                         Hardware
  5.  
  6.  
  7.  
  8.          "Never let a domestic quarrel ruin a day's writing. If you can't start
  9.          the next day fresh, get rid of your wife."
  10.  
  11.                                                                       Mario Puzo
  12.  
  13.  
  14.          This chapter describes the objects included in the totSYS unit. There
  15.          are four objects in all, designed to provide information about the
  16.          hardware and operating system on which an application is running. Dis-
  17.          playOBJ is an object relating to the monitor/display card; EquipOBJ
  18.          returns information about the peripheral devices installed on the
  19.          computer; MemOBJ provides information about base, extended and expanded
  20.          memory; OSOBJ provides information about the operating system and the
  21.          DOS configurable international settings.
  22.  
  23.          A full example illustrating the use of each object can be found at the
  24.          end of the chapter.
  25.  
  26.  
  27. Using DisplayOBJ
  28.          The public methods (i.e. the methods you should be calling) in Display-
  29.          OBJ are designed to provide you with information about the computer
  30.          display. Since other units in the Toolkit also need to know this
  31.          information, a global instance, called Monitor, is automatically ini-
  32.          tialized when the totSYS unit is used. Monitor is, in fact, a pointer
  33.          to an object on the heap, and has to be referenced with the pointer
  34.          symbol, e.g. Monitor^. There should be no reason to initialize another
  35.          DisplayOBJ, just access the Monitor^ methods. The following methods are
  36.          available:
  37.  
  38.  
  39.          SnowProne: boolean
  40.          This function method returns true if the display is a "snowy" CGA.
  41.          Since the screen writing routines in totFAST take care of snow, you
  42.          should not normally need to call this method.
  43.  
  44.  
  45.          GetMode:byte
  46.          Returns the current display mode, e.g. mode 3 is 80 column color mode.
  47.          Refer to the Turbo Pascal Programmer's Guide or a DOS Technical Refer-
  48.          ence for more information about display modes.
  49.  
  50.  
  51.          ColorOn:boolean
  52.  
  53. 4-2                                                                 User's Guide
  54. --------------------------------------------------------------------------------
  55.  
  56.          This function returns true if the system is capable of color display.
  57.          This function is normally called to determine whether to use monochrome
  58.          or color display attributes when overriding the Toolkit's defaults.
  59.          This function will always return false if ForceBW is set to true (dis-
  60.          cussed next). It also returns false if the user is using a color sys-
  61.          tem, but has set the device to BW80 mode.
  62.  
  63.  
  64.          SetBW(On:boolean)
  65.          Call this procedure and pass a true value if you want to force the
  66.          system to use monochrome values. This is useful for laptop systems
  67.          where the system responds as a color device, but the user only sees
  68.          gray (or orange!) scales. Because LookTOT was initialized before your
  69.          program code was executed, you should also call LookTOT^.SetDefaults,
  70.          and LookTOT will then be assigned the default monochrome settings.
  71.  
  72.  
  73.          DisplayType: tVideo
  74.          The totSYS unit defines an enumerated type tVideo which has the follow-
  75.          ing members: UnKnown, Mono, CGA, MCGAmono, MCGAcol, EGAmono, EGAcol,
  76.          VGAmono and VGAcol. The function display type checks the installed
  77.          hardware and returns the appropriate member.
  78.  
  79.  
  80.          BaseOfScreen: pointer;
  81.          This function returns a pointer to the base address of video memory.
  82.          This is $B800:0000 for color systems and $B000:0000 for monochrome.
  83.          Unless you are using non-Toolkit routines to directly access video
  84.          memory, you should not need to call this method.
  85.  
  86.  
  87.          Width: byte
  88.          This function returns the width of the display in characters, which is
  89.          commonly a value of 80.
  90.  
  91.  
  92.          Depth: byte
  93.          This function returns the depth of the display in lines. In normal
  94.          display mode the function will return 25, but in condensed mode an EGA
  95.          system will return 43, and a VGA system will return 50.
  96.  
  97.  
  98.          The following two methods are used to switch an EGA or VGA display
  99.          system between condensed and normal modes.
  100.  
  101.  
  102.          SetCondensed: byte;
  103.  
  104.  
  105.  
  106.  
  107. Hardware                                                                     4-3
  108. --------------------------------------------------------------------------------
  109.  
  110.          This function tries to set the display to condensed mode, and returns
  111.          the number of text lines the system can display in condensed mode. Note
  112.          that only EGA and VGA systems can be set into condensed mode.
  113.  
  114.  
  115.  
  116. 4-4                                                                 User's Guide
  117. --------------------------------------------------------------------------------
  118.  
  119.  
  120.          Set25;
  121.  
  122.          This procedure forces the display into 25 line mode.
  123.  
  124.  
  125.  
  126.  
  127. Using EquipOBJ
  128.          The EquipOBJ object is designed to provide information about the
  129.          installed hardware devices. Most of the EquipOBJ methods reflect the
  130.          data which the user defined with the SETUP operating system command.
  131.          This may not correspond with the actual physical configuration, but is
  132.          the only configuration which DOS will allow software to access. Equi-
  133.          pOBJ includes the following methods:
  134.  
  135.  
  136.          ComputerID:byte;
  137.          This function returns a byte indicating the basic system type. The
  138.          computer ID was implemented by IBM to provide an easy way for differen-
  139.          tiating between the various IBM personal computers. The following list
  140.          shows the hexadecimal values of the IBM range:
  141.  
  142.          $FF     - IBM PC
  143.          $FE,$FB - IBM XT or portable
  144.          $FD     - the infamous PC Junior
  145.          $FC     - IBM AT, XT-286, PS/2 50 and 60
  146.          $FA     - PS/2 25 and 30
  147.          $F9     - IBM PC Convertible
  148.          $F8     - PS/2 80
  149.  
  150.          Some non-IBM systems do not follow this convention, and an unlisted
  151.          number may be returned by this method.
  152.  
  153.  
  154.          ParallelPorts: byte;
  155.          This function returns the number of installed parallel ports (LPTx).
  156.  
  157.  
  158.          SerialPorts: byte;
  159.          This function returns the number of installed serial ports (COMx).
  160.  
  161.  
  162.          FloppyDrives: byte;
  163.          This function returns the number of physical diskette drives.
  164.  
  165.  
  166.          ROMDate: string;
  167.  
  168.  
  169.  
  170. Hardware                                                                     4-5
  171. --------------------------------------------------------------------------------
  172.  
  173.          Returns an eight character string representing the ROM date in the
  174.          format MM/DD/YY.
  175.  
  176.  
  177.          GameAdapter: boolean;
  178.          Returns true if a game adapter is installed.
  179.  
  180.  
  181.          Serialprinter: boolean;
  182.          Returns true if a serial printer is configured.
  183.  
  184.  
  185.          MathChip: boolean;
  186.          Returns true if a math co-processor is detected. If you compile Toolkit
  187.          programs with the compiler directive FLOAT enabled, but FLOATEM dis-
  188.          abled, the program will only run on systems equipped with a math co-
  189.          processor. Use this function during program initialization to ensure
  190.          the host PC is adequately equipped.
  191.  
  192.  
  193.  
  194. Using MemOBJ
  195.          The MemOBJ methods provide data related to base, extended and expanded
  196.          memory on the host PC. The following function methods are provided:
  197.  
  198.  
  199.          BaseMemory: integer;
  200.          Returns the total amount of base memory installed, i.e. memory up to
  201.          640k. The value is returned in kilobytes ("k"). Remember that the Turbo
  202.          Pascal functions MemAvail and MaxAvail provide data on free memory,
  203.          i.e. memory not being used by device drivers and programs.
  204.  
  205.  
  206.          EMMInstalled: boolean;
  207.          Returns true if an expanded memory manager is installed.
  208.  
  209.  
  210.          EMMversionMajor: byte;
  211.          Returns the expanded memory manager major version number, i.e. the
  212.          whole portion of the version number. If an EMM is not installed, a 0 is
  213.          returned.
  214.  
  215.  
  216.          EMMversionMinor: byte;
  217.          Returns the expanded memory manager minor version number, i.e. the dec-
  218.          imal portion of the version number. If an EMM is not installed, or if
  219.          the minor version number is zero, a 0 is returned.
  220.  
  221.  
  222. 4-6                                                                 User's Guide
  223. --------------------------------------------------------------------------------
  224.  
  225.          EMMversion: string;
  226.  
  227.          Returns a three character string representing the complete EMM version
  228.          number, e.g. "4.0".
  229.  
  230.          MaxExpMem: word;
  231.  
  232.          Returns the total amount of installed expanded memory in kilobytes.
  233.  
  234.          ExpMemAvail: word;
  235.  
  236.          Returns the amount of unused (or available) expanded memory in kilo-
  237.          bytes.
  238.  
  239.          ExtMemAvail: word;
  240.  
  241.          Returns the amount of unused extended memory in kilobytes.
  242.  
  243.  
  244. Using OSOBJ
  245.  
  246.          The OSOBJ object is designed to provide information about the operating
  247.          system. This unit is particularly useful when programs need to be
  248.          developed for the international (read: non-American!) market place,
  249.          because the DOS configuration can be ascertained, including the date
  250.          format, currency symbol, country code, etc.
  251.          If you develop a program to be distributed internationally, you need to
  252.          adhere to the host countries' formatting conventions, especially date
  253.          and number formats. Refer to chapter 11: Controlling User Input for a
  254.          full discussion of this topic.
  255.  
  256.          The following function methods are available:
  257.  
  258.          OSVersionMajor: byte;
  259.  
  260.          Returns the major DOS version number, e.g. 2, 3 or 4.
  261.  
  262.          OSVersionMinor: byte;
  263.  
  264.          Returns the minor DOS version number, e.g. 1.
  265.  
  266.          OSVersion: string;
  267.  
  268.          Returns the full DOS version number as a string, e.g. "3.1"
  269.  
  270.          Country: word;
  271.  
  272.  
  273. Hardware                                                                     4-7
  274. --------------------------------------------------------------------------------
  275.  
  276.          Returns a word which represents the country code. In general, the coun-
  277.          try codes are the same as the 3-digit international phone access code.
  278.          Some of the more common codes are:
  279.  
  280.                 001   United States
  281.                 002   Canada (French)
  282.                 003   Latin America
  283.                 031   Netherlands
  284.                 032   Belgium
  285.                 033   France
  286.                 034   Spain
  287.                 039   Italy
  288.                 041   Switzerland
  289.                 044   United Kingdom
  290.                 045   Denmark
  291.                 046   Sweden
  292.                 047   Norway
  293.                 049   Germany
  294.                 061   Australia
  295.                 351   Portugal
  296.                 358   Finland
  297.  
  298.          Currency: string;
  299.  
  300.          Returns a string identifying the country's currency abbreviation. On
  301.          systems using DOS prior to version 3.0, only a signal character can be
  302.          accessed. However, systems using DOS 3.0 and later may return more than
  303.          one character, e.g. FFR, DKR.
  304.  
  305.          DateFmt: tDate;
  306.  
  307.          The totSYS unit includes the declaration of the tDATE enumerated type
  308.          which has three members: USA, EUROPE and JAPAN. This function returns
  309.          the member which represents the operating system default date format.
  310.          Note that the three formats are MM-DD-YY, DD-MM-YY and YY-MM-DD,
  311.          respectively.
  312.  
  313.          ThousandsSep: char;
  314.  
  315.          Returns the character used to punctuate the thousands mark in numbers.
  316.          The USA uses a comma, whereas many other countries use a period or a
  317.          space.
  318.  
  319.          DecimalSep: char;
  320.  
  321.          Returns the character used to punctuate the decimal place. This is
  322.          usually a period or a comma.
  323.  
  324.  
  325.  
  326. 4-8                                                                 User's Guide
  327. --------------------------------------------------------------------------------
  328.  
  329.          DateSep: char;
  330.  
  331.          Returns the character used to separate the month, day and year elements
  332.          of a date, e.g. "/", "-". Note: this information is not accessible on
  333.          systems using DOS prior to version 3.0. If the machine does not have
  334.          DOS 3.0 or later, a '/' is returned.
  335.  
  336.          TimeSep: char;
  337.  
  338.          Returns the character used to separate the hours, minutes and seconds
  339.          when displaying the time, e.g. ":". Note: this information is not
  340.          accessible on systems using DOS prior to version 3.0. If the machine
  341.          does not have DOS 3.0 or later, a ':' is returned.
  342.  
  343.          TimeFmt: byte;
  344.  
  345.          Returns a byte to indicate the preferred time display. A 0 indicates a
  346.          12 hour format, and a 1 indicates a 24 hour format. Note: this informa-
  347.          tion is not accessible on systems using DOS prior to version 3.0. If
  348.          the machine does not have DOS 3.0 or later, a 0 is returned.
  349.  
  350.          CurrencyFmt: byte;
  351.  
  352.          Returns a byte indicating the currency format. One of the following
  353.          five values will be returned:
  354.               0     String leads currency, no space
  355.               1     String follows currency, no space
  356.               2     String leads currency, one space
  357.               3     String follows currency, one space
  358.               4     String replaces decimal separator
  359.  
  360.          Note: this information is not accessible on systems using DOS prior to
  361.          version 3.0. If the machine does not have DOS 3.0 or later, a 0 is
  362.          returned.
  363.  
  364.          CurrencyDecPlaces: byte;
  365.  
  366.          Returns the number of decimal places normally used with the country's
  367.          currency. Note: this information is not accessible on systems using DOS
  368.          prior to version 3.0. If the machine does not have DOS 3.0 or later, a
  369.          2 is returned.
  370.  
  371.  
  372.  
  373. Hardware                                                                     4-9
  374. --------------------------------------------------------------------------------
  375.  
  376. Example
  377.  
  378.          Listed below is the demo program, DEMSY1, which illustrates the use of
  379.          each of the four totSYS objects. Figure 4.1 reflects the resultant
  380.          output on a VGA computer.
  381.           Program DemoSystemOne;
  382.           {DEMSY1}
  383.  
  384.           USES DOS,CRT, TOTSYS;
  385.           var
  386.              Equip: EquipObj;
  387.              Mem: MemObj;
  388.              OS: OSObj;
  389.              Lines: byte;
  390.           begin
  391.             ClrScr;
  392.             Lines := Monitor^.SetCondensed;
  393.             if Monitor^.ColorOn then
  394.                writeln('This system is color')
  395.             else
  396.                writeln('This system is monochrome');
  397.             with Equip do
  398.             begin
  399.                Init;
  400.                Writeln('Machine ID: ',ComputerID);
  401.                Writeln('Parallel Ports: ',ParallelPorts);
  402.                Writeln('Serial Ports: ',SerialPorts);
  403.                Writeln('Floppy Drives: ',Floppydrives);
  404.                Writeln('ROM date: ',RomDate);
  405.                Writeln('Game Adapter: ',GameAdapter);
  406.                Writeln('Serial printer: ',Serialprinter);
  407.                Writeln('Math Coprocessor: ',MathChip);
  408.                Writeln;
  409.             end;
  410.  
  411.             with Mem do
  412.             begin
  413.                Init;
  414.                Writeln('Base memory: ',Basememory,'k');
  415.                Writeln('Avail Extended memory: ',ExtMemAvail,'k');
  416.                if EMMInstalled then
  417.                begin
  418.                   Writeln('Total Expanded memory: ',MaxExpMem,'k');
  419.                   Writeln('Avail Expanded memory: ',ExpMemAvail,'k');
  420.                   Writeln('Expanded memory manager version: '+
  421.                           EMMversion);
  422.                end
  423.                else
  424.  
  425.  
  426.  
  427. 4-10                                                                User's Guide
  428. --------------------------------------------------------------------------------
  429.  
  430.                   Writeln('Expanded memory not installed: ');
  431.                writeln;
  432.             end;
  433.  
  434.             with OS do
  435.             begin
  436.                Init;
  437.                Writeln('Operating System Version: '+OSversion);
  438.                Writeln('Country Code: ',Country);
  439.                write('Currency String: ',Currency,' ');
  440.                case CurrencyFmt of
  441.                   0: writeln('(String leads currency, no space)');
  442.                   1: writeln('(String follows currency, no space)');
  443.                   2: writeln('(String leads currency, one space)');
  444.                   3: writeln('(String follows currency, one space)');
  445.                   4: writeln('(String replaces decimal separator)');
  446.                end; {case}
  447.                writeln('Currency Decimal Places: ',CurrencyDecPlaces);
  448.                write('Thousands Separator: ','''',ThousandsSep,'''');
  449.                writeln(' Decimal Separator: ','''',DecimalSep,'''');
  450.                case DateFmt of
  451.                   USA: writeln('Date Format: MM DD YY');
  452.                   Europe: writeln('Date Format: DD MM YY');
  453.                   Japan: writeln('Date Format: YY MM DD');
  454.                end; {case}
  455.                write('Date separator: ','''',DateSep,'''');
  456.                writeln(' Time separator: ','''',TimeSep,'''');
  457.                if TimeFmt = 0 then
  458.                   writeln('Time is displayed on a 12 hour clock')
  459.                else
  460.                   writeln('Time is displayed on a 24 hour clock');
  461.             end;
  462.             write('                            press any key ...');
  463.             Repeat until keypressed;
  464.             if Lines > 25 then
  465.                Monitor^.Set25;
  466.           end.
  467.          Notice that the INIT method is not called for the Monitor^ instance.
  468.          This is because Monitor^ is a global instance, and the Toolkit automat-
  469.          ically initializes all global instances.
  470.  
  471.  
  472. Figure 4.1                                                              [SCREEN]
  473. The System Demo
  474. Program
  475.